package cn.itsource.ymcc.controller;

import cn.itsource.ymcc.doc.CourseDoc;
import cn.itsource.ymcc.dto.CourserSearchDto;
import cn.itsource.ymcc.result.JSONResult;
import cn.itsource.ymcc.result.PageList;
import cn.itsource.ymcc.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SearchController {
    @Autowired
    private ISearchService searchService;
    @PostMapping("/saveCourse")
    public JSONResult saveCourse(@RequestBody CourseDoc doc){
        searchService.saveCourse(doc);
        return JSONResult.success();
    }
    @PostMapping("/course/search")
    public PageList<CourseDoc> search(@RequestBody CourserSearchDto dto) {
        return searchService.search(dto);
    }
    /**
     * 删除课程
     */
    @PostMapping("/course/deleteCourse")
    public JSONResult deleteCourse(@RequestBody Long courseId) {
        searchService.deleteCourse(courseId);
        return JSONResult.success();
    }
}
